﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Com.CMS263.PO;
using Com.CMS263.DAO;

namespace Com.CMS263.BLL
{
    public class ProdGoodsAttrBLL : BaseBLL<ProdGoodsAttr>
    {
        ProdGoodsAttrDAO eaDAO = new ProdGoodsAttrDAO();
        public ProdGoodsAttr entity = new ProdGoodsAttr();
        public override ProdGoodsAttr GetModel()
        {
            return entity;
        }
        ///// <summary>
        ///// 根据基本文章
        ///// </summary>
        ///// <param name="artId"></param>
        ///// <param name="typeId"></param>
        ///// <returns></returns>
        //public IList<string> GetShowInBackValue(int artId, int attrId)
        //{
        //    ExtAttributeBLL eaBLL=new ExtAttributeBLL();
        //    IList<ExtAttribute> attrList = eaBLL.GetShowInBackAttrByTypeId(attrId);
        //    IList<String> valList = new List<string>();
        //    //循环扩展属性表根据属性编号和和文章编号得到某个属性的值
        //    foreach (ExtAttribute item in attrList)
        //    {
        //        string val = "";
        //        if (item.attrType == 4)
        //        {
        //            val ="<img src='/ArtUpFile/"+ this.GetValueById(artId, item.id)+"'/>";
        //        }
        //        else
        //        {
        //            val = this.GetValueById(artId, item.id);
        //        }
        //        valList.Add(val);
        //    }
        //    return valList;
        //}
        /// <summary>
        /// 根据文章编号和属性编号得到这个属性的值
        /// </summary>
        /// <param name="artId">基本文章编号</param>
        /// <param name="attrId">属性编号</param>
        /// <returns></returns>
        public string GetValueById(int goodsId, int attrId)
        {
            string val = "";
            val = eaDAO.GetValueById(goodsId, attrId);
            return val;
        }
        /// <summary>
        /// 根据编号和属性查询这个对象
        /// </summary>
        /// <param name="artId"></param>
        /// <param name="attrId"></param>
        /// <returns></returns>
        public ProdGoodsAttr GetExtValueById(int goodsId, int attrId)
        {
            return eaDAO.GetExtValueById(goodsId, attrId);
        }

        #region 根据ProdTypeId查询个数
        /// <summary>
        /// 根据ProdTypeId查询个数
        /// </summary>
        /// <param name="ptid"></param>
        /// <returns></returns>
        public int GetCountByProdTypeId(int ptid)
        {
            return eaDAO.GetCountByProdTypeId(ptid);
        }
        #endregion


        #region 根据Prodtypeid删除相关信
        /// <summary>
        /// 根据Prodtypeid删除相关信
        /// </summary>
        /// <param name="ptid"></param>
        /// <returns></returns>
        public int DelByProdTypeId(int ptid)
        {
            return eaDAO.DelByProdTypeId(ptid);
        }
        #endregion

        public IList<ProdGoodsAttr> FindListByGoodsId(int id)
        {
            return eaDAO.FindListByGoodsId(id);
        }


        #region 根据AttrId查询个数
        /// <summary>
        /// 根据AttrId查询个数
        /// </summary>
        /// <param name="attrid"></param>
        /// <returns></returns>
        public int GetCountByAttrId(int attrid)
        {
            return eaDAO.GetCountByAttrId(attrid);
        }
        #endregion

        #region 根据AttrId删除相关信息
        /// <summary>
        /// 根据AttrId删除相关信息
        /// </summary>
        /// <param name="attrid"></param>
        /// <returns></returns>
        public int DelByAttrId(int attrid)
        {
            return eaDAO.DelByAttrId(attrid);
        }
        #endregion       
    
        public void DelBygooId(int goodId)
        {
            eaDAO.DelBygooId(goodId);
        }
    }
}
